home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SunSoft Catalyst CDWARE 1996 May to August
/
Catalyst CDWARE 1996 May to August.iso
/
.products
/
JavaWorld
/
javaworld
/
cgi-bin
/
jw-subscribe.cgi
< prev
next >
Wrap
Text File
|
1996-02-25
|
3KB
|
136 lines
#!/usr/local/bin/perl
# jw-subscribe - script to process subscription forms for JavaWorld.
$subject="JW subscription";
$recipient="submaster\@javaworld.com";
$from="jw-subscribe\@javaworld.com";
$mailprog="/usr/lib/sendmail";
$date=`date`; chop($date);
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/,$buffer);
foreach $pair (@pairs)
{
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;
}
# check for empty form; thwart bastards
$flag0=0;
$flag1=0;
$flag2a=0;
$flag2b=0;
$flag3=0;
$flag4=0;
$flag5=0;
$flag6=0;
if ($FORM{'name'} =~ /[A-Za-z]/ && $FORM{'email'} =~ /[A-Za-z]/) {
$flag0++;
}
if ($FORM{'business.other'} =~ /[A-Za-z]*/) {
$flag1++;
}
if ($FORM{'installedos.other'} =~ /[A-Za-z]*/) {
$flag4++;
}
if ($FORM{'primaryos.other'} =~ /[A-Za-z]*/) {
$flag5++;
}
if ($FORM{'prod.other'} =~ /[A-Za-z]*/) {
$flag6++;
}
foreach $i (keys %FORM) {
if ($i =~ /^business$/) {
$flag1++;
}
elsif ($i =~ /^primjob\./) {
$flag2a++;
}
elsif ($i =~ /^employees$/) {
$flag3++;
}
elsif ($i =~ /^installedos\./) {
$flag4++;
}
elsif ($i =~ /^primaryos\./) {
$flag5++;
}
elsif ($i =~ /^prod\./) {
$flag6++;
}
}
if ($flag0 && $flag1 && $flag2a && $flag3 && $flag4 && $flag5 && $flag6) {
print <<END_OF_MESSAGE;
Content-TYPE: text/html
<HTML>
<HEAD><TITLE>JavaWorld Subscription Response</TITLE></HEAD>
<BODY>
<H3>Thank you for subscribing to <EM>JavaWorld</EM>. We appreciate your
patronage. Send any questions, comments, or suggestions to
editors\@javaworld.com</H3>
</BODY>
</HTML>
END_OF_MESSAGE
# send data to JW HQ
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL "BEGIN RECORD $date\n";
print MAIL "CONTENT_LENGTH=$ENV{'CONTENT_LENGTH'}\n";
print MAIL "CONTENT_TYPE=$ENV{'CONTENT_TYPE'}\n";
print MAIL "DOCUMENT_ROOT=$ENV{'DOCUMENT_ROOT'}\n";
print MAIL "GATEWAY_INTERFACE=$ENV{'GATEWAY_INTERFACE'}\n";
print MAIL "HTTP_REFERER=$ENV{'HTTP_REFERER'}\n";
print MAIL "HTTP_USER_AGENT=$ENV{'HTTP_USER_AGENT'}\n";
print MAIL "QUERY_STRING=$ENV{'QUERY_STRING'}\n";
print MAIL "REMOTE_ADDR=$ENV{'REMOTE_ADDR'}\n";
print MAIL "REMOTE_HOST=$ENV{'REMOTE_HOST'}\n";
print MAIL "REQUEST_METHOD=$ENV{'REQUEST_METHOD'}\n";
print MAIL "SCRIPT_NAME=$ENV{'SCRIPT_NAME'}\n";
print MAIL "SERVER_NAME=$ENV{'SERVER_NAME'}\n";
print MAIL "SERVER_PORT=$ENV{'SERVER_PORT'}\n";
print MAIL "SERVER_PROTOCOL=$ENV{'SERVER_PROTOCOL'}\n";
print MAIL "SERVER_SOFTWARE=$ENV{'SERVER_SOFTWARE'}\n";
print MAIL "ARGV=$ARGV[0]\n";
print MAIL "STDINDATA=$buffer\n";
print MAIL "END RECORD $date\n";
close(MAIL);
} # end of if bastard else sendmail
else {
print <<END_OF_MESSAGE;
Content-TYPE: text/html
<HTML>
<HEAD><TITLE>JavaWorld-Incomplete Subscription Response</TITLE></HEAD>
<BODY>
<H3>An incomplete form was detected. It must contain a name, e-mail address,
and responses to questions one through six.</H3>
<H3>To finish subscribing to <EM>JavaWorld</EM>, return to the
subscription form by hitting your browser's back button.</H3>
</BODY>
</HTML>
END_OF_MESSAGE
}
exit 0;